﻿using HDUSampling.HDUControls.HTools.LoadingFrm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HMI.View
{
    /// <summary>
    /// ContainWin.xaml 的交互逻辑
    /// </summary>
    public partial class ContainWin : UserControl
    {
        public ContainWin()
        {
            
            InitializeComponent();

        }
        public Action<int> selectTab { get; set; }
        public int selectIndex = 1;
        // set 改变当前选选项卡样式
        public int SelectIndex
        {
            get { return selectIndex; }
            set
            {
                for (int i = 1; i <= 6; i++)
                {
                    if (i == Convert.ToInt32(value))
                    {
                        hea.SelectedIndex = Convert.ToInt32(value) - 1;
                        TabItem tabItem = ((TabItem)hea.Items[Convert.ToInt32(value) - 1]);
                        SolidColorBrush brushbk = new SolidColorBrush();
                        brushbk.Color = Colors.Purple;
                        tabItem.Background = brushbk;
                        SolidColorBrush brushfore = new SolidColorBrush();
                        brushfore.Color = Colors.White;
                        tabItem.Foreground = brushfore;
                        selectIndex = value;
                    }
                    else
                    {
                        TabItem tabItem = ((TabItem)hea.Items[i - 1]);
                        SolidColorBrush brushbk = new SolidColorBrush();
                        brushbk.Color = Colors.Plum;
                        tabItem.Background = brushbk;
                        SolidColorBrush brushfore = new SolidColorBrush();
                        brushfore.Color = Colors.Black;
                        tabItem.Foreground = brushfore;
                    }
                }
            }
        }

        private void hea_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TabItem tab = hea.SelectedItem as TabItem;
            if (tab != null)
            {
                selectIndex =Convert.ToInt32( tab.Name.Replace("tab", ""));

                if (selectTab != null)
                {
                    selectTab(selectIndex);
                }
            }
        }


    }
}
